<template>
  <div>
    <a-card :bordered="false">
      <f-search-form ref="search" :more="false" @searchHandler="searchHandler">
        <f-search-form-item label="部门" name="deptId" type="select" :data="api.dept.list" :params='{auth:1}' value-key="deptId" label-key="deptName" @change='deptChange' style="width: 250px"/>
        <f-search-form-item label="单号" name="orderNo" style="width: 250px"/>
        <f-search-form-item label="购方" name="customName" style="width: 220px"/>
        <f-search-form-item label="返款状态" name="supplierRefundState" type="select" :data="api.busOrder.refundState"></f-search-form-item>
        <f-search-form-item label="发货日期(起)" type="date"  name="beginDate" style="width: 300px"/>
        <f-search-form-item label="发货日期(止)" type="date"  name="endDate" style="width: 300px"/>
        <f-search-form-item label="返款日期(起)" type="date" slot="advanced" name="refundDate1" style="width: 250px"/>
        <f-search-form-item label="返款日期(终)" type="date" slot="advanced" name="refundDate2" style="width: 250px"/>
      </f-search-form>
      <a-tabs @tabClick="tabClick" :defaultActiveKey="current" v-model="current">
        <a-tab-pane tab="待结算" key="form1">
          <settle-no ref="form1"  v-if="current=='form1'"></settle-no>
        </a-tab-pane>
        <a-tab-pane tab="待退保证金" key="form2">
          <cbreturn-no ref="form2"  v-if="current=='form2'"></cbreturn-no>
        </a-tab-pane>
        <a-tab-pane tab="结算单" key="form3">
          <settle-yes ref="form3" v-if="current=='form3'"></settle-yes>
        </a-tab-pane>
        <a-tab-pane tab="退保证金单" key="form4">
          <cbreturn-yes ref="form4" v-if="current=='form4'"></cbreturn-yes>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </div>
</template>
<script>

  import api from './../js/api'
  import SettleNo from './tab1'
  import SettleYes from './tab2'
  import CbreturnNo from '@/views/module/business/order/cbreturn/tab1'
  import CbreturnYes from '@/views/module/business/order/cbreturn/tab2'

  export default {
    name: 'Tabs',
    components: { CbreturnYes, CbreturnNo, SettleNo, SettleYes },
    data() {
      let me = this
      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        searchParams: {
          orderNo:''
        },
        current: 'form1',
        forms: [
          'form1',
          'form2',
          'form3',
          'form4',
          'form5'
        ]
      }
    },
    created() {
    },
    methods: {
      tabClick(name) {
        this.current = name
        this.$nextTick(() => {
          this.searchHandler(this.searchParams)
        })
      },
      deptChange(value){

        this.$refs.search.queryParam.deptId=value;
        this.searchHandler(this.$refs.search.queryParam);

      },
      searchHandler(searchParams) {
        this.searchParams = searchParams

        if( this.current=='form2')
        {
          this.$refs[this.current].openMultiple(searchParams)
        }
        this.$refs[this.current].searchHandler(searchParams)
      }
    }
  }
</script>
